import request from '@/utils/request'
import type R from '@/types/conduit/R'
import type { RiderSignUp, RiderPasswordLogin, RiderPhoneCodeLogin } from '@/types/param/rider'
import type AuthenticationTokens from '@/types/entity/AuthenticationTokens'
import type { RiderBasicInfo, CommonInfos } from '@/types/response/rider'
export const sendCodeForRiderRegister = (phoneAreaCode: string, phone: string): Promise<R<null>> =>
  request({
    url: `/rider/rider/sendCodeForRiderRegister`,
    method: 'GET',
    params: { phoneAreaCode, phone }
  })
export const register = (data: RiderSignUp): Promise<R<null>> =>
  request({
    url: `/rider/rider/register`,
    method: 'POST',
    data
  })

export const passwordLogin = (data: RiderPasswordLogin): Promise<R<AuthenticationTokens>> =>
  request({
    url: `/rider/rider/passwordLogin`,
    method: 'POST',
    data
  })
export const phoneCodeLogin = (data: RiderPhoneCodeLogin): Promise<R<AuthenticationTokens>> =>
  request({
    url: `/rider/rider/phoneCodeLogin`,
    method: 'POST',
    data
  })
export const sendCodeForRiderLogin = (phoneAreaCode: string, phone: string): Promise<R<null>> =>
  request({
    url: `/rider/rider/sendCodeForRiderLogin`,
    method: 'GET',
    params: { phoneAreaCode, phone }
  })
export const refreshToken = (accessToken: string): Promise<R<AuthenticationTokens>> =>
  request({
    url: `/rider/rider/refreshToken`,
    method: 'GET',
    params: { accessToken }
  })

export const queryCommonInfos = (): Promise<R<CommonInfos>> =>
  request({
    url: `/rider/rider/common-infos`,
    method: 'GET'
  })
export const changeWorkStatus = (workStatus: number): Promise<R<null>> =>
  request({
    url: `/rider/rider/change-work-status/${workStatus}`,
    method: 'POST'
  })
export const removeRiderGeo = (): Promise<R<null>> =>
  request({
    url: `/rider/rider/remove-rider-geo`,
    method: 'POST'
  })
